package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.TravelContractRefund;
import com.eling.elcms.travel.model.view.TravelContractRefundView;
import com.eling.elcms.travel.service.ITravelContractRefundManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class TravelContractRefundController extends BaseFormController{

	@Autowired
	private ITravelContractRefundManager travelContractRefundManager;
	
	@RequestMapping("/api/travelcontractrefund/query")
	@ResponseBody
	public List<TravelContractRefund> query(@ModelAttribute TravelContractRefund cond) {
		return travelContractRefundManager.query(cond);
	}

	@RequestMapping("/api/travelcontractrefund/search")
	@ResponseBody
	public List<TravelContractRefund> search(@ModelAttribute SearchCondition sc, @ModelAttribute TravelContractRefund cond) {
		sc.setQueryCondition(cond);
		return travelContractRefundManager.search(sc);
	}

	@RequestMapping("/api/travelcontractrefund/save")
	@ResponseBody
	public TravelContractRefund save(@ModelAttribute @ModelFilling TravelContractRefund cond) {
		return travelContractRefundManager.save(cond);
	}
	
	@RequestMapping("/api/travelcontractrefund/{pkTravelContractRefund}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkTravelContractRefund) {
		travelContractRefundManager.remove(pkTravelContractRefund);
		return new Msg("删除成功");
	}
	
	/**
	 * 签约退费 列表查询接口
	 * **/
	@RequestMapping("/api/travelcontractrefund/queryrefund")
	@ResponseBody
	public List<TravelContractRefundView> queryRefund(@ModelAttribute TravelContractRefund cond) {
		return travelContractRefundManager.queryRefund(cond);
	}
	
	/**
	 * 退费接口
	 * **/
	@RequestMapping("/api/travelcontractrefund/saverefund")
	@ResponseBody
	public TravelContractRefund saveRefund(@ModelAttribute TravelContractRefund cond) {
		return travelContractRefundManager.saveRefund(cond);
	}
	
	@RequestMapping("/api/travelcontractrefund/searchrefund")
	@ResponseBody
	public List<TravelContractRefundView> searchRefund(@ModelAttribute SearchCondition sc, @ModelAttribute TravelContractRefund cond) {
		sc.setQueryCondition(cond);
		return travelContractRefundManager.searchRefund(sc);
	}
}
